package com.tx.springboot_demo.controller;

import com.tx.springboot_demo.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ：tx
 * @description：
 * @date ：Created in 2019/4/9 17:25
 * @modified By：
 * @version:
 */
@Controller
@RequestMapping("/loginController")
public class LoginController {

    @RequestMapping("/login")
    @ResponseBody
    public Map<String,Object> login(User user, HttpServletRequest request){
        Map<String,Object> map = new HashMap<>();
        if(user != null){
            request.getSession().setAttribute("user",user);
            map.put("result",1);
        }
        return map;
    }
}
